﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Itasa.API
{
    internal class Version : IComparable, IComparable<Version>
    {

        internal String VersionName { get; private set; }
        internal List<Season> Seasons { get; private set; }

        internal Version(String Version)
        {
            this.VersionName = Version;
            this.Seasons = new List<Season>();
        }

        internal void AddSub(Sub s)
        {
            String se = s.Season();
            Season tmp = new Season(se);
            if (Seasons.Contains(tmp)) tmp = Seasons[Seasons.IndexOf(tmp)];
            else Seasons.Add(tmp);
            tmp.AddSub(s);
        }

        public override bool Equals(object obj)
        {
            if (obj is Version) return this.VersionName.Equals((obj as Version).VersionName);
            return false;
        }

        public int CompareTo(object obj)
        {
            if (obj is Version) return this.VersionName.CompareTo((obj as Version).VersionName);
            return 0;
        }

        public int CompareTo(Version other)
        {
            if (other == null) throw new ArgumentNullException("other");
            return this.VersionName.CompareTo(other.VersionName);
        }
    }
}
